package com.santiao.youxiang.utils

import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.drawable.Drawable
import android.widget.RadioButton

object ElseUtil {
    @SuppressLint("UseCompatLoadingForDrawables")
    fun RadioButton.setDrawableForRadioButton(myActivity:Activity, id:Int, width:Int, length:Int){
        val drawable: Drawable?=myActivity.getDrawable(id)
        drawable?.setBounds(0,0,ScreenUtils.dip2px(width,myActivity),ScreenUtils.dip2px(length,myActivity))
        this.setCompoundDrawables(null,drawable,null,null)
    }

    //判断两个List是否有元素变化
    fun <T> List<T>.changedIndices(newList: List<T>): List<Int> {
        if (this.size != newList.size) {
            throw IllegalArgumentException("Lists should be of the same size")
        }
        val changedIndices = mutableListOf<Int>()
        this.zip(newList).forEachIndexed { index, (oldItem, newItem) ->
            if (oldItem != newItem) {
                changedIndices.add(index)
            }
        }
        return changedIndices
    }
}